package com.cet.designpatterns.iterator;

import java.util.Iterator;
import java.util.List;

/**
 * @program: algorithm
 * @description:
 * @author: 陈恩涛
 * @create: 2021-09-21 22:38
 **/
public class InfoCollegeIterator implements Iterator {

    private List<Department> departmentList;
    private int index;

    public InfoCollegeIterator(List<Department> departmentList) {
        this.departmentList = departmentList;
        index = 0;
    }

    @Override
    public boolean hasNext() {
        return departmentList != null
                && index < departmentList.size();
    }

    @Override
    public Object next() {
        return departmentList.get(index++);
    }

    @Override
    public void remove() {
        throw new UnsupportedOperationException();
    }
}
